﻿using System;
using System.IO;
using System.Web;
using System.Xml;

namespace YueRu.Common
{
    public class ConfigHelper
    {
        public static string GetConfig(XmlDocument doc, string path)
        {
            var node = doc.SelectSingleNode(path);
            if (node == null) throw new Exception("未能找到" + path + "节点");
            return node.InnerText;
        }

        public static XmlDocument LoadConfig(string path)
        {
            var xmlPath = HttpContext.Current.Server.MapPath(path);
            if (!File.Exists(xmlPath)) throw new Exception("未能找到支付宝配置文件(" + path + ")");
            var doc = new XmlDocument();
            doc.Load(xmlPath);
            return doc;
        }
    }
}
